<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>订单管理</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready(
			function() {
				//$("#name").focus();
				$("#inputForm")
						.validate(
								{
									submitHandler : function(form) {
										loading('正在提交，请稍等...');
										form.submit();
									},
									errorContainer : "#messageBox",
									errorPlacement : function(error, element) {
										$("#messageBox").text("输入有误，请先更正。");
										if (element.is(":checkbox")
												|| element.is(":radio")
												|| element.parent().is(
														".input-append")) {
											error.appendTo(element.parent()
													.parent());
										} else {
											error.insertAfter(element);
										}
									}
								});
			});
	function changeID(orderCode,id, itemId, type) {
		var loginName = $("#" + id + "").val();
		var trackStaffUserLoginName = "";
		if('2' == type)
		{
			loginName = $("#" + id + "supervisorUser").val();
			trackStaffUserLoginName = $("#" + id + "trackStaffUser").val();
		}

		$.ajax({
			//提交数据的类型 POST GET
			type : "POST",
			//提交的网址
			url : "${ctx}/order/userOrder/change",
			//提交的数据
			data : {
				"orderCode" : orderCode,
				"itemId" : itemId,
				"type" : type,
				"loginName" : loginName,
				"trackStaffUserLoginName":trackStaffUserLoginName
			},
			//返回数据的格式
			datatype : "text",//"xml", "html", "script", "json", "jsonp", "text".
			//在请求之前调用的函数
			beforeSend : function() {
			},
			//成功返回之后调用的函数             
			success : function(data) {
				alert(data);
			},
			//调用执行后调用的函数
			complete : function(XMLHttpRequest, textStatus) {
			},
			//调用出错执行的函数
			error : function() {
			}
		});
	}
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/order/userOrder/">订单列表</a></li>
		<li class="active"><a
			href="${ctx}/order/userOrder/form?id=${orderPojo.userOrder.id}">订单<shiro:hasPermission
					name="order:userOrder:edit">${not empty OrderPojo.userOrder.id?'修改':'详情'}</shiro:hasPermission>
				<shiro:lacksPermission name="order:userOrder:edit">查看</shiro:lacksPermission></a></li>
	</ul>
	<br />
	<table id="contentTable"
		class="table table-striped table-bordered table-condensed">
		<tr>
			<td>订单号：</td>
			<td><label>${orderPojo.userOrder.orderCode}</label></td>
		</tr>
		<tr>
			<td>用户：</td>
			<td><label>${orderPojo.userOrder.user.loginName}</label></td>
		</tr>
		<tr>
			<td>地址信息标示。：</td>
			<td><label>${orderPojo.userOrder.userAddr.address}</label></td>
		</tr>
		<tr>
			<td>联系信息：</td>
			<td><label>${orderPojo.userOrder.contactId}</label></td>
		</tr>
		<tr>
			<td>订单状态：</td>
			<td>
			<label>
			<c:if test="${orderPojo.userOrder.orderState == '1'}"> 待处理
    			</c:if> 
			<c:if test="${orderPojo.userOrder.orderState == '2'}">待签字
    			</c:if> 
			<c:if test="${orderPojo.userOrder.orderState == '3'}">施工中
    			</c:if> 
			<c:if test="${orderPojo.userOrder.orderState == '4'}">已完成
    			</c:if> 
			<c:if test="${orderPojo.userOrder.orderState == '5'}">已取消
    			</c:if> 
			</label>
			</td>
		</tr>
		<tr>
			<td>订单类型：</td>
		<td><label>
			<c:if test="${orderPojo.userOrder.orderType == '1'}">安装订单
    			</c:if> 
			<c:if test="${orderPojo.userOrder.orderType == '2'}">设计订单
    			</c:if> 
			<c:if test="${orderPojo.userOrder.orderType == '3'}">无订单的售后订单
    			</c:if> 
			<c:if test="${orderPojo.userOrder.orderType == '4'}">有订单的售后订单
    			</c:if> 
			</label>
			</td>
		</tr>
		<tr>
			<td>总金额：</td>
			<td><label>${orderPojo.userOrder.itemPrice}</label></td>
		</tr>
		<c:if test="${'3' != orderPojo.userOrder.orderType and  '4' != orderPojo.userOrder.orderType}">
		<tr>
			<td>跟踪人：</td>
			<td><input type="text"
				id="${orderPojo.userOrder.omOrderTrack.id}trackStaffUser"
				value=" ${orderPojo.userOrder.omOrderTrack.trackStaffUser.loginName}" />
			<button
				onclick="changeID('${orderPojo.userOrder.orderCode}','${orderPojo.userOrder.omOrderTrack.id}trackStaffUser','${orderPojo.userOrder.omOrderTrack.id}','1')">修改</button></td>
		</tr>
		<tr>
			<td>质保期：</td>
			<td><input type="text"
				id="${orderPojo.userOrder.orderCode}warrantyTime"
				value=" ${orderPojo.userOrder.warrantyTime}" />天
			<button
				onclick="changeID('${orderPojo.userOrder.orderCode}','${orderPojo.userOrder.orderCode}warrantyTime','${orderPojo.userOrder.omOrderTrack.id}','3')">修改</button></td>
		</tr>
		</c:if>
		<c:if test="${'3' == orderPojo.userOrder.orderType or  '4' == orderPojo.userOrder.orderType}">
		<tr>
			<td>售后负责人：</td>
			<td><input type="text"
				id="${orderPojo.userOrder.omOrderTrack.id}trackStaffUser"
				value=" ${orderPojo.userOrder.omOrderTrack.trackStaffUser.loginName}" />
			<button
				onclick="changeID('${orderPojo.userOrder.orderCode}','${orderPojo.userOrder.omOrderTrack.id}trackStaffUser','${orderPojo.userOrder.omOrderTrack.id}','4')">修改</button></td>
		</tr>
		</c:if>
		<tr>
			<td>备注：</td>
			<td><label>${orderPojo.userOrder.comments}</label></td>
		</tr>
		<tr>
			<td>竣工时间</td>
			<td><label>${orderPojo.userOrder.finishDate}</label></td>
		</tr>
	</table>



	<div class="control-group">
		<label class="control-label">工单：</label>
		<div class="controls">
			<table id="contentTable"
				class="table table-striped table-bordered table-condensed">
				<thead>
					<tr>
						<th>工单id</th>
						<th>工单类型</th>
						<th>负责人</th>
						<!-- <th>名称</th> -->
						<th>监理电话</th>
						<th>操作</th>
						</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${orderPojo.omOrderTrackList}" var="omOrderTrack">
						<tr>
							<td>${omOrderTrack.id}</td>
							<td>
								<!-- 	sale("0", "销售工单"), install("1", "安装工单"), design("2", "设计工单"), purchase("3", "采购工单"),service("4", "售后工单"),; -->
								<c:if test="${omOrderTrack.type == '0'}">
    				销售工单
    			</c:if> <c:if test="${omOrderTrack.type == '1'}">
    				安装工单
    			</c:if> <c:if test="${omOrderTrack.type == '2'}">
    				设计工单
    			</c:if> <c:if test="${omOrderTrack.type == '3'}">
    				采购工单
    			</c:if> <c:if test="${omOrderTrack.type == '4'}">
    				售后工单
    			</c:if>
							</td>
							 <c:if test="${omOrderTrack.type != '4'}">
    				<td>${omOrderTrack.trackStaffUser.loginName}</td>
    			</c:if>
						 <c:if test="${omOrderTrack.type == '4'}">
    				<td>
    				<input type="text" id="${omOrderTrack.id}trackStaffUser"
								value=" ${omOrderTrack.trackStaffUser.loginName}" />
    				</td>
    			</c:if>	
				<td><input type="text" id="${omOrderTrack.id}supervisorUser"
					value=" ${omOrderTrack.supervisorUser.loginName}" /></td>
				<td>
					<button
						onclick="changeID('${omOrderTrack.orderCode}','${omOrderTrack.id}','${omOrderTrack.id}','2')">修改</button>
				</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
	</div>
	<%-- <div class="form-actions">
			<shiro:hasPermission name="order:userOrder:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div> --%>
	<%-- </form:form> --%>
</body>
</html>